package domainfinder.data.test;

import org.apache.xmlrpc.XmlRpcException;

import at.sternwerk.domainfinder.data.xmlrpc.Connector;
import at.sternwerk.domainfinder.data.xmlrpc.types.ArrayElement;
import at.sternwerk.domainfinder.data.xmlrpc.types.Element;
import at.sternwerk.domainfinder.data.xmlrpc.types.MapElement;

public class InwxJavaExample {

  public static void main(String args[]) throws XmlRpcException {
    System.out.println("Starting inwx Java example ...");
    Connector connector;
    String username = "your username";
    String password = "your password";

    connector = new Connector();

    if ( !connector.login(username, password)) {
      System.out.println("Could not log in with username '" + username + "' and password '" + password + "'");
      return;
    }

    ArrayElement myDomains = connector.checkDomain("inwx23werew4rewr.de");

    for (Element item : myDomains.getArray()) {
      MapElement _item = (MapElement) item;
      System.out.println("tld: " + _item.get("tld").toString());
      System.out.println("name: " + _item.get("name").toString());
      System.out.println("domain: " + _item.get("domain").toString());
      System.out.println("status: " + _item.get("status").toString());
      System.out.println("price: " + _item.get("price").toString());
    }

    ArrayElement domains = connector.getAllNS();
    for (Element item : domains.getArray()) {
      MapElement _item = (MapElement) item;
      System.out.println(_item.get("domain") + ":" + _item.get("type"));
    }

    // connector.getNS("inwx.de");

    connector.logout();
    System.out.println("logout");

  }

}
